package com.blog.controller;

import com.blog.Utils.Result;
import com.blog.bean.dto.ChapterDTO;
import com.blog.service.ChapterService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 任浩
 * @version 1.0
 */

@RestController
@RequestMapping("/chapter")
public class ChapterController {

    @Autowired
    private ChapterService chapterService;


    /**
     * 新增章节
     * @param chapterDTO
     * @return
     */
    @PostMapping("/add")
    public Result add(@RequestBody ChapterDTO chapterDTO){
        return chapterService.add(chapterDTO);
    }

    /**
     * 查询课程下的所有章节和视频
     * @param id
     * @return
     */
    @GetMapping("/getByCourseId")
    public Result getByCourseId(@RequestParam("courseId") Integer id){
        return chapterService.getByCourseId(id);
    }


    /**
     * 查询课程下的所有章节
     * @param id
     * @return
     */
    @GetMapping("/getChapter")
    public Result getChapter(@RequestParam("courseId") Integer id){
        return chapterService.getChapter(id);
    }


}
